﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace ZLCMS.Web.SystemManage.Control
{
    public partial class CascadeComboxControl : System.Web.UI.UserControl
    {

        public CascadeComboxControl()
        {

            EmptyKey = "-1";
            EmptyText = "--请选择--";
        }

        protected void Page_Load(object sender, EventArgs e)
        {


        }

        protected override void Render(HtmlTextWriter writer)
        {
            cascadeSelect.Attributes.Add("selected_value", _selectedVal);
            cascadeSelect.Attributes.Add("ref", ReferenceCategory);
            cascadeSelect.Attributes.Add("data_url", DataSourceUrl);
            cascadeSelect.Attributes.Add("category", Category);
            cascadeSelect.Attributes.Add("group", Group);
            cascadeSelect.Attributes.Add("empty_key", EmptyKey);
            cascadeSelect.Attributes.Add("empty_text", EmptyText);

            if (!string.IsNullOrEmpty(ConditionName))
            {
                cascadeSelect.Attributes.Add("cond", ConditionName);
            }

            base.Render(writer);
        }

        private string _selectedVal;
        

        /// <summary>
        /// 当前选中值
        /// </summary>
        public string SelectedValue { get { return Request[cascadeSelect.Name]; } set { _selectedVal = value; } }

        /// <summary>
        /// 级联分组
        /// </summary>
        public string Group { get; set; }

        /// <summary>
        /// 目录
        /// </summary>
        public string Category { get; set; }

        /// <summary>
        /// 下级目录
        /// </summary>
        public string ReferenceCategory { get; set; }


        /// <summary>
        /// 数据源获取路径
        /// </summary>
        public string DataSourceUrl { get; set; }

        /// <summary>
        /// 默认值
        /// </summary>
        public string EmptyKey { get; set; }


        /// <summary>
        /// 默认标题
        /// </summary>
        public string EmptyText { get; set; }

        /// <summary>
        /// 查询条件
        /// </summary>
        public string ConditionName { get; set; }
    }
}